import cryptoJs from "crypto-js";

const APPID = "efc89f3d";

export function upstream(task, text, success) {
  const business = {
    aue: "lame",
    sfl: 1,
    auf: "audio/L16;rate=16000",
    vcn: "xiaoyan"
  };

  const upData = {
    status: 2,
    text: cryptoJs.enc.Base64.stringify(text)
  };

  task.send({
    data: JSON.stringify({
      common: {
        app_id: APPID
      },
      business,
      data: upData
    })
  });
  task.onMessage(success);
  task.onError(err => console.log(err))
}